package com.google.gwt.gwtpages.client.page.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.gwtpages.client.PageRequestSession;
import com.google.gwt.gwtpages.client.page.AsyncPageCallback;
import com.google.gwt.gwtpages.client.page.CompositePage;
import com.google.gwt.gwtpages.client.page.TransientPage;
import com.google.gwt.gwtpages.client.page.parameters.PageParameters;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.HTMLPanel;

public class DefaultPageEnterErrorPage extends CompositePage implements
		TransientPage {

	interface _UiBinder extends UiBinder<HTMLPanel, DefaultPageEnterErrorPage> {
	}

	private static _UiBinder uiBinder = GWT.create(_UiBinder.class);

	@UiField
	SpanElement pageToken;
	@UiField
	SpanElement message;

	public DefaultPageEnterErrorPage(String pageToken, Throwable cause) {
		initWidget(uiBinder.createAndBindUi(this));
		this.pageToken.setInnerText(pageToken);
		String message = cause.getMessage();
		if (null == message) message = "(null)";
		this.message.setInnerText(message);
		cause.printStackTrace();
	}
	
	public void onEnterPage(PageParameters parameters,
			PageRequestSession session, AsyncPageCallback callback) {
	}

	public void onExitPage() {
	}
}